package com.zx.onlineeducation.service.cms.controller;

import com.zx.onlineeducation.common.util.R;
import com.zx.onlineeducation.service.cms.entity.BannerDO;
import com.zx.onlineeducation.service.cms.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 轮播图 前台 前端控制器
 * </p>
 *
 * @author 郑雪
 * @since 2022-01-23
 */
@Api(tags = "轮播图前台接口")
@RestController
@RequestMapping("/cms/banner/front")
@CrossOrigin // 解决跨域
public class BannerFrontController {

    /**
     * 轮播图服务接口
     */
    @Autowired
    private BannerService bannerService;

    @ApiOperation("获取首页轮播图列表")
    @GetMapping("/all")
    public R getAll(
            @ApiParam(value = "显示条数，默认为3条")
            @RequestParam(value = "limit", required = false, defaultValue = "3") Integer limit) {
        // 获取数据列表
        List<BannerDO> list = bannerService.getAll(limit);
        // 返回结果
        return R.ok().data("list", list);
    }

}

